<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">日期筛选</label>
                            <div class="layui-input-inline">
                                <input type="text" name="search_date" id="start_time"  placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <div class="layui-col-md12" style="margin-top:20px;">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div id="echarts-records" style="width: 100%;min-height:500px"></div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form', 'table','laydate','echarts'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            echarts = layui.echarts,
            laydate=layui.laydate;
        // 上架开始日期
        var insShelf = laydate.render({
            elem: '#start_time',
            calendar: true,
            type: 'date',
            done: function (value, date) {

            }
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            roulette_static(data.field.search_date);
            return false;
        });

        var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
        roulette_static();
        // echarts 窗口缩放自适应
        window.onresize = function(){
            echartsRecords.resize();
        }
        /**
         * 报表功能
         */
        function roulette_static(search_date='')
        {

            $.ajax({
              url:'/admin/Imdata/chat_activity_static?action=ajax',
                type:'post',
                dataType:'json',
                data:{
                    search_date,
                },
                success:function(res){
                  if(res.status){
                      var optionRecords = {
                          tooltip: {
                              trigger: 'axis'
                          },
                          legend: {
                              data:['活跃人数']
                          },
                          grid: {
                              left: '3%',
                              right: '4%',
                              bottom: '3%',
                              containLabel: true
                          },
                          toolbox: {
                              feature: {
                                  saveAsImage: {}
                              }
                          },
                          xAxis: {
                              type: 'category',
                              boundaryGap: false,
                              data: res.date_array
                          },
                          yAxis: {
                              type: 'value'
                          },
                          series:res.data_array
                      };
                      echartsRecords.setOption(optionRecords);
                  }

                }
            });

        }
    });
</script>

</body>
</html>